<html>

<head>
  <%- include('../partials/admin-head') %>
</head>

<body>

<%- include('../partials/panel-header', {active: 'content'}) %>

<main>
  <form class="new-post" action="/posts" method="post">
    <fieldset>
      <label for="title">New post</label>
      <input type="text" id="title" placeholder="Title" name="title" autofocus />
      <div class="new-post-draft">
        <label>
          <input type="checkbox" name="draft" id="draft" value="Draft" />Draft
        </label>
      </div>
      <input type="submit" value="Create" />
    </fieldset>
  </form>

  <% for (var page of pages) { %>
    <div class="page">
      <div class="page-url">
        <% if (page.draft) { %>
          <a href="<%- page.url + '/edit' %>"><%- page.title %> [draft]</a>
        <% } else { %>
          <a href="<%- page.url %>"><%- page.title %></a>
        <% } %>
      </div>
      <div class="page-edit">
        <a href="<%- page.url + '/edit' %>">Edit</a>
        <a onclick="return confirm('Permanently delete post?')" href="<%- page.url + '/delete' %>">Delete</a>
      </div>
    </div>
  <% } %>

</main>
</body>
</html>
